
/*
===============================================================================
                    EntitySpaces Studio by EntitySpaces, LLC
             Persistence Layer and Business Objects for Microsoft .NET
             EntitySpaces(TM) is a legal trademark of EntitySpaces, LLC
                          http://www.entityspaces.net
===============================================================================
EntitySpaces Version : 2012.1.0930.0
EntitySpaces Driver  : SQL
Date Generated       : 2016/3/21 1:39:12
===============================================================================
*/

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
using System.Data;
using System.ComponentModel;
using System.Xml.Serialization;
using System.Runtime.Serialization;

using EntitySpaces.Core;
using EntitySpaces.Interfaces;
using EntitySpaces.DynamicQuery;



namespace yncTech.BusinessObjects
{
	/// <summary>
	/// Encapsulates the 'T_S_CodeTable' table
	/// </summary>

    [DebuggerDisplay("Data = {Debug}")]
	[Serializable]
	[DataContract]
	[KnownType(typeof(TSCodeTable))]	
	[XmlType("TSCodeTable")]
	public partial class TSCodeTable : esTSCodeTable
	{	
		[DebuggerBrowsable(DebuggerBrowsableState.RootHidden | DebuggerBrowsableState.Never)]
		protected override esEntityDebuggerView[] Debug
		{
			get { return base.Debug; }
		}

		override public esEntity CreateInstance()
		{
			return new TSCodeTable();
		}
		
		#region Static Quick Access Methods
		static public void Delete(System.Decimal codeID)
		{
			var obj = new TSCodeTable();
			obj.CodeID = codeID;
			obj.AcceptChanges();
			obj.MarkAsDeleted();
			obj.Save();
		}

	    static public void Delete(System.Decimal codeID, esSqlAccessType sqlAccessType)
		{
			var obj = new TSCodeTable();
			obj.CodeID = codeID;
			obj.AcceptChanges();
			obj.MarkAsDeleted();
			obj.Save(sqlAccessType);
		}
		#endregion

		
					
		
	
	}



    [DebuggerDisplay("Count = {Count}")]
	[Serializable]
	[CollectionDataContract]
	[XmlType("TSCodeTableCollection")]
	public partial class TSCodeTableCollection : esTSCodeTableCollection, IEnumerable<TSCodeTable>
	{
		public TSCodeTable FindByPrimaryKey(System.Decimal codeID)
		{
			return this.SingleOrDefault(e => e.CodeID == codeID);
		}

		
		
		#region WCF Service Class
		
		[DataContract]
		[KnownType(typeof(TSCodeTable))]
		public class TSCodeTableCollectionWCFPacket : esCollectionWCFPacket<TSCodeTableCollection>
		{
			public static implicit operator TSCodeTableCollection(TSCodeTableCollectionWCFPacket packet)
			{
				return packet.Collection;
			}

			public static implicit operator TSCodeTableCollectionWCFPacket(TSCodeTableCollection collection)
			{
				return new TSCodeTableCollectionWCFPacket() { Collection = collection };
			}
		}
		
		#endregion
		
				
	}



    [DebuggerDisplay("Query = {Parse()}")]
	[Serializable]	
	public partial class TSCodeTableQuery : esTSCodeTableQuery
	{
		public TSCodeTableQuery():this("TSCodeTableQuery")
		{
		}
		public TSCodeTableQuery(string joinAlias)
		{
			this.es.JoinAlias = joinAlias;
		}	

		override protected string GetQueryName()
		{
			return "TSCodeTableQuery";
		}
		
					
	
		#region Explicit Casts
		
		public static explicit operator string(TSCodeTableQuery query)
		{
			return TSCodeTableQuery.SerializeHelper.ToXml(query);
		}

		public static explicit operator TSCodeTableQuery(string query)
		{
			return (TSCodeTableQuery)TSCodeTableQuery.SerializeHelper.FromXml(query, typeof(TSCodeTableQuery));
		}
		
		#endregion		
	}

	[DataContract]
	[Serializable]
	abstract public partial class esTSCodeTable : esEntity
	{
		public esTSCodeTable()
		{

		}
		
		#region LoadByPrimaryKey
		public virtual bool LoadByPrimaryKey(System.Decimal codeID)
		{
			if(this.es.Connection.SqlAccessType == esSqlAccessType.DynamicSQL)
				return LoadByPrimaryKeyDynamic(codeID);
			else
				return LoadByPrimaryKeyStoredProcedure(codeID);
		}

		public virtual bool LoadByPrimaryKey(esSqlAccessType sqlAccessType, System.Decimal codeID)
		{
			if (sqlAccessType == esSqlAccessType.DynamicSQL)
				return LoadByPrimaryKeyDynamic(codeID);
			else
				return LoadByPrimaryKeyStoredProcedure(codeID);
		}

		private bool LoadByPrimaryKeyDynamic(System.Decimal codeID)
		{
			TSCodeTableQuery query = new TSCodeTableQuery();
			query.Where(query.CodeID == codeID);
			return this.Load(query);
		}

		private bool LoadByPrimaryKeyStoredProcedure(System.Decimal codeID)
		{
			esParameters parms = new esParameters();
			parms.Add("CodeID", codeID);
			return this.Load(esQueryType.StoredProcedure, this.es.spLoadByPrimaryKey, parms);
		}
		#endregion
		
		#region Properties
		
		
		
		/// <summary>
		/// Maps to T_S_CodeTable.CodeID
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Decimal? CodeID
		{
			get
			{
				return base.GetSystemDecimal(TSCodeTableMetadata.ColumnNames.CodeID);
			}
			
			set
			{
				if(base.SetSystemDecimal(TSCodeTableMetadata.ColumnNames.CodeID, value))
				{
					OnPropertyChanged(TSCodeTableMetadata.PropertyNames.CodeID);
				}
			}
		}		
		
		/// <summary>
		/// Maps to T_S_CodeTable.CodeCategory
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String CodeCategory
		{
			get
			{
				return base.GetSystemString(TSCodeTableMetadata.ColumnNames.CodeCategory);
			}
			
			set
			{
				if(base.SetSystemString(TSCodeTableMetadata.ColumnNames.CodeCategory, value))
				{
					OnPropertyChanged(TSCodeTableMetadata.PropertyNames.CodeCategory);
				}
			}
		}		
		
		/// <summary>
		/// Maps to T_S_CodeTable.Code
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String Code
		{
			get
			{
				return base.GetSystemString(TSCodeTableMetadata.ColumnNames.Code);
			}
			
			set
			{
				if(base.SetSystemString(TSCodeTableMetadata.ColumnNames.Code, value))
				{
					OnPropertyChanged(TSCodeTableMetadata.PropertyNames.Code);
				}
			}
		}		
		
		/// <summary>
		/// Maps to T_S_CodeTable.CodeDesc
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String CodeDesc
		{
			get
			{
				return base.GetSystemString(TSCodeTableMetadata.ColumnNames.CodeDesc);
			}
			
			set
			{
				if(base.SetSystemString(TSCodeTableMetadata.ColumnNames.CodeDesc, value))
				{
					OnPropertyChanged(TSCodeTableMetadata.PropertyNames.CodeDesc);
				}
			}
		}		
		
		/// <summary>
		/// Maps to T_S_CodeTable.CodeSequence
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? CodeSequence
		{
			get
			{
				return base.GetSystemInt32(TSCodeTableMetadata.ColumnNames.CodeSequence);
			}
			
			set
			{
				if(base.SetSystemInt32(TSCodeTableMetadata.ColumnNames.CodeSequence, value))
				{
					OnPropertyChanged(TSCodeTableMetadata.PropertyNames.CodeSequence);
				}
			}
		}		
		
		/// <summary>
		/// Maps to T_S_CodeTable.Value1
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String Value1
		{
			get
			{
				return base.GetSystemString(TSCodeTableMetadata.ColumnNames.Value1);
			}
			
			set
			{
				if(base.SetSystemString(TSCodeTableMetadata.ColumnNames.Value1, value))
				{
					OnPropertyChanged(TSCodeTableMetadata.PropertyNames.Value1);
				}
			}
		}		
		
		/// <summary>
		/// Maps to T_S_CodeTable.Value2
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String Value2
		{
			get
			{
				return base.GetSystemString(TSCodeTableMetadata.ColumnNames.Value2);
			}
			
			set
			{
				if(base.SetSystemString(TSCodeTableMetadata.ColumnNames.Value2, value))
				{
					OnPropertyChanged(TSCodeTableMetadata.PropertyNames.Value2);
				}
			}
		}		
		
		/// <summary>
		/// Maps to T_S_CodeTable.NumValue1
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Decimal? NumValue1
		{
			get
			{
				return base.GetSystemDecimal(TSCodeTableMetadata.ColumnNames.NumValue1);
			}
			
			set
			{
				if(base.SetSystemDecimal(TSCodeTableMetadata.ColumnNames.NumValue1, value))
				{
					OnPropertyChanged(TSCodeTableMetadata.PropertyNames.NumValue1);
				}
			}
		}		
		
		/// <summary>
		/// Maps to T_S_CodeTable.NumValue2
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Decimal? NumValue2
		{
			get
			{
				return base.GetSystemDecimal(TSCodeTableMetadata.ColumnNames.NumValue2);
			}
			
			set
			{
				if(base.SetSystemDecimal(TSCodeTableMetadata.ColumnNames.NumValue2, value))
				{
					OnPropertyChanged(TSCodeTableMetadata.PropertyNames.NumValue2);
				}
			}
		}		
		
		/// <summary>
		/// Maps to T_S_CodeTable.EffectiveStartDate
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.DateTime? EffectiveStartDate
		{
			get
			{
				return base.GetSystemDateTime(TSCodeTableMetadata.ColumnNames.EffectiveStartDate);
			}
			
			set
			{
				if(base.SetSystemDateTime(TSCodeTableMetadata.ColumnNames.EffectiveStartDate, value))
				{
					OnPropertyChanged(TSCodeTableMetadata.PropertyNames.EffectiveStartDate);
				}
			}
		}		
		
		/// <summary>
		/// Maps to T_S_CodeTable.EffectiveEndDate
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.DateTime? EffectiveEndDate
		{
			get
			{
				return base.GetSystemDateTime(TSCodeTableMetadata.ColumnNames.EffectiveEndDate);
			}
			
			set
			{
				if(base.SetSystemDateTime(TSCodeTableMetadata.ColumnNames.EffectiveEndDate, value))
				{
					OnPropertyChanged(TSCodeTableMetadata.PropertyNames.EffectiveEndDate);
				}
			}
		}		
		
		/// <summary>
		/// Maps to T_S_CodeTable.ParentID
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Decimal? ParentID
		{
			get
			{
				return base.GetSystemDecimal(TSCodeTableMetadata.ColumnNames.ParentID);
			}
			
			set
			{
				if(base.SetSystemDecimal(TSCodeTableMetadata.ColumnNames.ParentID, value))
				{
					OnPropertyChanged(TSCodeTableMetadata.PropertyNames.ParentID);
				}
			}
		}		
		
		/// <summary>
		/// Maps to T_S_CodeTable.MapPath
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String MapPath
		{
			get
			{
				return base.GetSystemString(TSCodeTableMetadata.ColumnNames.MapPath);
			}
			
			set
			{
				if(base.SetSystemString(TSCodeTableMetadata.ColumnNames.MapPath, value))
				{
					OnPropertyChanged(TSCodeTableMetadata.PropertyNames.MapPath);
				}
			}
		}		
		
		/// <summary>
		/// Maps to T_S_CodeTable.CreatedBy
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String CreatedBy
		{
			get
			{
				return base.GetSystemString(TSCodeTableMetadata.ColumnNames.CreatedBy);
			}
			
			set
			{
				if(base.SetSystemString(TSCodeTableMetadata.ColumnNames.CreatedBy, value))
				{
					OnPropertyChanged(TSCodeTableMetadata.PropertyNames.CreatedBy);
				}
			}
		}		
		
		/// <summary>
		/// Maps to T_S_CodeTable.CreatedDate
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.DateTime? CreatedDate
		{
			get
			{
				return base.GetSystemDateTime(TSCodeTableMetadata.ColumnNames.CreatedDate);
			}
			
			set
			{
				if(base.SetSystemDateTime(TSCodeTableMetadata.ColumnNames.CreatedDate, value))
				{
					OnPropertyChanged(TSCodeTableMetadata.PropertyNames.CreatedDate);
				}
			}
		}		
		
		/// <summary>
		/// Maps to T_S_CodeTable.LastedUpdatedBy
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String LastedUpdatedBy
		{
			get
			{
				return base.GetSystemString(TSCodeTableMetadata.ColumnNames.LastedUpdatedBy);
			}
			
			set
			{
				if(base.SetSystemString(TSCodeTableMetadata.ColumnNames.LastedUpdatedBy, value))
				{
					OnPropertyChanged(TSCodeTableMetadata.PropertyNames.LastedUpdatedBy);
				}
			}
		}		
		
		/// <summary>
		/// Maps to T_S_CodeTable.LastedUpdatedDate
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.DateTime? LastedUpdatedDate
		{
			get
			{
				return base.GetSystemDateTime(TSCodeTableMetadata.ColumnNames.LastedUpdatedDate);
			}
			
			set
			{
				if(base.SetSystemDateTime(TSCodeTableMetadata.ColumnNames.LastedUpdatedDate, value))
				{
					OnPropertyChanged(TSCodeTableMetadata.PropertyNames.LastedUpdatedDate);
				}
			}
		}		
		
		/// <summary>
		/// Maps to T_S_CodeTable.VersionNo
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? VersionNo
		{
			get
			{
				return base.GetSystemInt32(TSCodeTableMetadata.ColumnNames.VersionNo);
			}
			
			set
			{
				if(base.SetSystemInt32(TSCodeTableMetadata.ColumnNames.VersionNo, value))
				{
					OnPropertyChanged(TSCodeTableMetadata.PropertyNames.VersionNo);
				}
			}
		}		
		
		#endregion	

		#region .str() Properties
		
		public override void SetProperties(IDictionary values)
		{
			foreach (string propertyName in values.Keys)
			{
				this.SetProperty(propertyName, values[propertyName]);
			}
		}
		
		public override void SetProperty(string name, object value)
		{
			esColumnMetadata col = this.Meta.Columns.FindByPropertyName(name);
			if (col != null)
			{
				if(value == null || value is System.String)
				{				
					// Use the strongly typed property
					switch (name)
					{							
						case "CodeID": this.str().CodeID = (string)value; break;							
						case "CodeCategory": this.str().CodeCategory = (string)value; break;							
						case "Code": this.str().Code = (string)value; break;							
						case "CodeDesc": this.str().CodeDesc = (string)value; break;							
						case "CodeSequence": this.str().CodeSequence = (string)value; break;							
						case "Value1": this.str().Value1 = (string)value; break;							
						case "Value2": this.str().Value2 = (string)value; break;							
						case "NumValue1": this.str().NumValue1 = (string)value; break;							
						case "NumValue2": this.str().NumValue2 = (string)value; break;							
						case "EffectiveStartDate": this.str().EffectiveStartDate = (string)value; break;							
						case "EffectiveEndDate": this.str().EffectiveEndDate = (string)value; break;							
						case "ParentID": this.str().ParentID = (string)value; break;							
						case "MapPath": this.str().MapPath = (string)value; break;							
						case "CreatedBy": this.str().CreatedBy = (string)value; break;							
						case "CreatedDate": this.str().CreatedDate = (string)value; break;							
						case "LastedUpdatedBy": this.str().LastedUpdatedBy = (string)value; break;							
						case "LastedUpdatedDate": this.str().LastedUpdatedDate = (string)value; break;							
						case "VersionNo": this.str().VersionNo = (string)value; break;
					}
				}
				else
				{
					switch (name)
					{	
						case "CodeID":
						
							if (value == null || value is System.Decimal)
								this.CodeID = (System.Decimal?)value;
								OnPropertyChanged(TSCodeTableMetadata.PropertyNames.CodeID);
							break;
						
						case "CodeSequence":
						
							if (value == null || value is System.Int32)
								this.CodeSequence = (System.Int32?)value;
								OnPropertyChanged(TSCodeTableMetadata.PropertyNames.CodeSequence);
							break;
						
						case "NumValue1":
						
							if (value == null || value is System.Decimal)
								this.NumValue1 = (System.Decimal?)value;
								OnPropertyChanged(TSCodeTableMetadata.PropertyNames.NumValue1);
							break;
						
						case "NumValue2":
						
							if (value == null || value is System.Decimal)
								this.NumValue2 = (System.Decimal?)value;
								OnPropertyChanged(TSCodeTableMetadata.PropertyNames.NumValue2);
							break;
						
						case "EffectiveStartDate":
						
							if (value == null || value is System.DateTime)
								this.EffectiveStartDate = (System.DateTime?)value;
								OnPropertyChanged(TSCodeTableMetadata.PropertyNames.EffectiveStartDate);
							break;
						
						case "EffectiveEndDate":
						
							if (value == null || value is System.DateTime)
								this.EffectiveEndDate = (System.DateTime?)value;
								OnPropertyChanged(TSCodeTableMetadata.PropertyNames.EffectiveEndDate);
							break;
						
						case "ParentID":
						
							if (value == null || value is System.Decimal)
								this.ParentID = (System.Decimal?)value;
								OnPropertyChanged(TSCodeTableMetadata.PropertyNames.ParentID);
							break;
						
						case "CreatedDate":
						
							if (value == null || value is System.DateTime)
								this.CreatedDate = (System.DateTime?)value;
								OnPropertyChanged(TSCodeTableMetadata.PropertyNames.CreatedDate);
							break;
						
						case "LastedUpdatedDate":
						
							if (value == null || value is System.DateTime)
								this.LastedUpdatedDate = (System.DateTime?)value;
								OnPropertyChanged(TSCodeTableMetadata.PropertyNames.LastedUpdatedDate);
							break;
						
						case "VersionNo":
						
							if (value == null || value is System.Int32)
								this.VersionNo = (System.Int32?)value;
								OnPropertyChanged(TSCodeTableMetadata.PropertyNames.VersionNo);
							break;
					

						default:
							break;
					}
				}
			}
            else if (this.ContainsColumn(name))
            {
                this.SetColumn(name, value);
            }
			else
			{
				throw new Exception("SetProperty Error: '" + name + "' not found");
			}
		}		

		public esStrings str()
		{
			if (esstrings == null)
			{
				esstrings = new esStrings(this);
			}
			return esstrings;
		}

		sealed public class esStrings
		{
			public esStrings(esTSCodeTable entity)
			{
				this.entity = entity;
			}
			
	
			public System.String CodeID
			{
				get
				{
					System.Decimal? data = entity.CodeID;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.CodeID = null;
					else entity.CodeID = Convert.ToDecimal(value);
				}
			}
				
			public System.String CodeCategory
			{
				get
				{
					System.String data = entity.CodeCategory;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.CodeCategory = null;
					else entity.CodeCategory = Convert.ToString(value);
				}
			}
				
			public System.String Code
			{
				get
				{
					System.String data = entity.Code;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.Code = null;
					else entity.Code = Convert.ToString(value);
				}
			}
				
			public System.String CodeDesc
			{
				get
				{
					System.String data = entity.CodeDesc;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.CodeDesc = null;
					else entity.CodeDesc = Convert.ToString(value);
				}
			}
				
			public System.String CodeSequence
			{
				get
				{
					System.Int32? data = entity.CodeSequence;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.CodeSequence = null;
					else entity.CodeSequence = Convert.ToInt32(value);
				}
			}
				
			public System.String Value1
			{
				get
				{
					System.String data = entity.Value1;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.Value1 = null;
					else entity.Value1 = Convert.ToString(value);
				}
			}
				
			public System.String Value2
			{
				get
				{
					System.String data = entity.Value2;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.Value2 = null;
					else entity.Value2 = Convert.ToString(value);
				}
			}
				
			public System.String NumValue1
			{
				get
				{
					System.Decimal? data = entity.NumValue1;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.NumValue1 = null;
					else entity.NumValue1 = Convert.ToDecimal(value);
				}
			}
				
			public System.String NumValue2
			{
				get
				{
					System.Decimal? data = entity.NumValue2;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.NumValue2 = null;
					else entity.NumValue2 = Convert.ToDecimal(value);
				}
			}
				
			public System.String EffectiveStartDate
			{
				get
				{
					System.DateTime? data = entity.EffectiveStartDate;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.EffectiveStartDate = null;
					else entity.EffectiveStartDate = Convert.ToDateTime(value);
				}
			}
				
			public System.String EffectiveEndDate
			{
				get
				{
					System.DateTime? data = entity.EffectiveEndDate;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.EffectiveEndDate = null;
					else entity.EffectiveEndDate = Convert.ToDateTime(value);
				}
			}
				
			public System.String ParentID
			{
				get
				{
					System.Decimal? data = entity.ParentID;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.ParentID = null;
					else entity.ParentID = Convert.ToDecimal(value);
				}
			}
				
			public System.String MapPath
			{
				get
				{
					System.String data = entity.MapPath;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.MapPath = null;
					else entity.MapPath = Convert.ToString(value);
				}
			}
				
			public System.String CreatedBy
			{
				get
				{
					System.String data = entity.CreatedBy;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.CreatedBy = null;
					else entity.CreatedBy = Convert.ToString(value);
				}
			}
				
			public System.String CreatedDate
			{
				get
				{
					System.DateTime? data = entity.CreatedDate;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.CreatedDate = null;
					else entity.CreatedDate = Convert.ToDateTime(value);
				}
			}
				
			public System.String LastedUpdatedBy
			{
				get
				{
					System.String data = entity.LastedUpdatedBy;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.LastedUpdatedBy = null;
					else entity.LastedUpdatedBy = Convert.ToString(value);
				}
			}
				
			public System.String LastedUpdatedDate
			{
				get
				{
					System.DateTime? data = entity.LastedUpdatedDate;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.LastedUpdatedDate = null;
					else entity.LastedUpdatedDate = Convert.ToDateTime(value);
				}
			}
				
			public System.String VersionNo
			{
				get
				{
					System.Int32? data = entity.VersionNo;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.VersionNo = null;
					else entity.VersionNo = Convert.ToInt32(value);
				}
			}
			

			private esTSCodeTable entity;
		}
		
		[NonSerialized]
		private esStrings esstrings;		
		
		#endregion
		
		#region Housekeeping methods

		override protected IMetadata Meta
		{
			get
			{
				return TSCodeTableMetadata.Meta();
			}
		}

		#endregion		
		
		#region Query Logic

		public TSCodeTableQuery Query
		{
			get
			{
				if (this.query == null)
				{
					this.query = new TSCodeTableQuery();
					InitQuery(this.query);
				}

				return this.query;
			}
		}

		public bool Load(TSCodeTableQuery query)
		{
			this.query = query;
			InitQuery(this.query);
			return this.Query.Load();
		}
		
		protected void InitQuery(TSCodeTableQuery query)
		{
			query.OnLoadDelegate = this.OnQueryLoaded;
			
			if (!query.es2.HasConnection)
			{
				query.es2.Connection = ((IEntity)this).Connection;
			}			
		}

		#endregion
		
        [IgnoreDataMember]
		private TSCodeTableQuery query;		
	}



	[Serializable]
	abstract public partial class esTSCodeTableCollection : esEntityCollection<TSCodeTable>
	{
		#region Housekeeping methods
		override protected IMetadata Meta
		{
			get
			{
				return TSCodeTableMetadata.Meta();
			}
		}

		protected override string GetCollectionName()
		{
			return "TSCodeTableCollection";
		}

		#endregion		
		
		#region Query Logic

	#if (!WindowsCE)
		[BrowsableAttribute(false)]
	#endif
		public TSCodeTableQuery Query
		{
			get
			{
				if (this.query == null)
				{
					this.query = new TSCodeTableQuery();
					InitQuery(this.query);
				}

				return this.query;
			}
		}

		public bool Load(TSCodeTableQuery query)
		{
			this.query = query;
			InitQuery(this.query);
			return Query.Load();
		}

		override protected esDynamicQuery GetDynamicQuery()
		{
			if (this.query == null)
			{
				this.query = new TSCodeTableQuery();
				this.InitQuery(query);
			}
			return this.query;
		}

		protected void InitQuery(TSCodeTableQuery query)
		{
			query.OnLoadDelegate = this.OnQueryLoaded;
			
			if (!query.es2.HasConnection)
			{
				query.es2.Connection = ((IEntityCollection)this).Connection;
			}			
		}

		protected override void HookupQuery(esDynamicQuery query)
		{
			this.InitQuery((TSCodeTableQuery)query);
		}

		#endregion
		
		private TSCodeTableQuery query;
	}



	[Serializable]
	abstract public partial class esTSCodeTableQuery : esDynamicQuery
	{
		override protected IMetadata Meta
		{
			get
			{
				return TSCodeTableMetadata.Meta();
			}
		}	
		
		#region QueryItemFromName
		
        protected override esQueryItem QueryItemFromName(string name)
        {
            switch (name)
            {
				case "CodeID": return this.CodeID;
				case "CodeCategory": return this.CodeCategory;
				case "Code": return this.Code;
				case "CodeDesc": return this.CodeDesc;
				case "CodeSequence": return this.CodeSequence;
				case "Value1": return this.Value1;
				case "Value2": return this.Value2;
				case "NumValue1": return this.NumValue1;
				case "NumValue2": return this.NumValue2;
				case "EffectiveStartDate": return this.EffectiveStartDate;
				case "EffectiveEndDate": return this.EffectiveEndDate;
				case "ParentID": return this.ParentID;
				case "MapPath": return this.MapPath;
				case "CreatedBy": return this.CreatedBy;
				case "CreatedDate": return this.CreatedDate;
				case "LastedUpdatedBy": return this.LastedUpdatedBy;
				case "LastedUpdatedDate": return this.LastedUpdatedDate;
				case "VersionNo": return this.VersionNo;

                default: return null;
            }
        }		
		
		#endregion
		
		#region esQueryItems

		public esQueryItem CodeID
		{
			get { return new esQueryItem(this, TSCodeTableMetadata.ColumnNames.CodeID, esSystemType.Decimal); }
		} 
		
		public esQueryItem CodeCategory
		{
			get { return new esQueryItem(this, TSCodeTableMetadata.ColumnNames.CodeCategory, esSystemType.String); }
		} 
		
		public esQueryItem Code
		{
			get { return new esQueryItem(this, TSCodeTableMetadata.ColumnNames.Code, esSystemType.String); }
		} 
		
		public esQueryItem CodeDesc
		{
			get { return new esQueryItem(this, TSCodeTableMetadata.ColumnNames.CodeDesc, esSystemType.String); }
		} 
		
		public esQueryItem CodeSequence
		{
			get { return new esQueryItem(this, TSCodeTableMetadata.ColumnNames.CodeSequence, esSystemType.Int32); }
		} 
		
		public esQueryItem Value1
		{
			get { return new esQueryItem(this, TSCodeTableMetadata.ColumnNames.Value1, esSystemType.String); }
		} 
		
		public esQueryItem Value2
		{
			get { return new esQueryItem(this, TSCodeTableMetadata.ColumnNames.Value2, esSystemType.String); }
		} 
		
		public esQueryItem NumValue1
		{
			get { return new esQueryItem(this, TSCodeTableMetadata.ColumnNames.NumValue1, esSystemType.Decimal); }
		} 
		
		public esQueryItem NumValue2
		{
			get { return new esQueryItem(this, TSCodeTableMetadata.ColumnNames.NumValue2, esSystemType.Decimal); }
		} 
		
		public esQueryItem EffectiveStartDate
		{
			get { return new esQueryItem(this, TSCodeTableMetadata.ColumnNames.EffectiveStartDate, esSystemType.DateTime); }
		} 
		
		public esQueryItem EffectiveEndDate
		{
			get { return new esQueryItem(this, TSCodeTableMetadata.ColumnNames.EffectiveEndDate, esSystemType.DateTime); }
		} 
		
		public esQueryItem ParentID
		{
			get { return new esQueryItem(this, TSCodeTableMetadata.ColumnNames.ParentID, esSystemType.Decimal); }
		} 
		
		public esQueryItem MapPath
		{
			get { return new esQueryItem(this, TSCodeTableMetadata.ColumnNames.MapPath, esSystemType.String); }
		} 
		
		public esQueryItem CreatedBy
		{
			get { return new esQueryItem(this, TSCodeTableMetadata.ColumnNames.CreatedBy, esSystemType.String); }
		} 
		
		public esQueryItem CreatedDate
		{
			get { return new esQueryItem(this, TSCodeTableMetadata.ColumnNames.CreatedDate, esSystemType.DateTime); }
		} 
		
		public esQueryItem LastedUpdatedBy
		{
			get { return new esQueryItem(this, TSCodeTableMetadata.ColumnNames.LastedUpdatedBy, esSystemType.String); }
		} 
		
		public esQueryItem LastedUpdatedDate
		{
			get { return new esQueryItem(this, TSCodeTableMetadata.ColumnNames.LastedUpdatedDate, esSystemType.DateTime); }
		} 
		
		public esQueryItem VersionNo
		{
			get { return new esQueryItem(this, TSCodeTableMetadata.ColumnNames.VersionNo, esSystemType.Int32); }
		} 
		
		#endregion
		
	}


	
	public partial class TSCodeTable : esTSCodeTable
	{

		
		
	}
	



	[Serializable]
	public partial class TSCodeTableMetadata : esMetadata, IMetadata
	{
		#region Protected Constructor
		protected TSCodeTableMetadata()
		{
			m_columns = new esColumnMetadataCollection();
			esColumnMetadata c;

			c = new esColumnMetadata(TSCodeTableMetadata.ColumnNames.CodeID, 0, typeof(System.Decimal), esSystemType.Decimal);
			c.PropertyName = TSCodeTableMetadata.PropertyNames.CodeID;
			c.IsInPrimaryKey = true;
			c.IsAutoIncrement = true;
			c.NumericPrecision = 18;
			m_columns.Add(c);
				
			c = new esColumnMetadata(TSCodeTableMetadata.ColumnNames.CodeCategory, 1, typeof(System.String), esSystemType.String);
			c.PropertyName = TSCodeTableMetadata.PropertyNames.CodeCategory;
			c.CharacterMaxLength = 30;
			m_columns.Add(c);
				
			c = new esColumnMetadata(TSCodeTableMetadata.ColumnNames.Code, 2, typeof(System.String), esSystemType.String);
			c.PropertyName = TSCodeTableMetadata.PropertyNames.Code;
			c.CharacterMaxLength = 50;
			m_columns.Add(c);
				
			c = new esColumnMetadata(TSCodeTableMetadata.ColumnNames.CodeDesc, 3, typeof(System.String), esSystemType.String);
			c.PropertyName = TSCodeTableMetadata.PropertyNames.CodeDesc;
			c.CharacterMaxLength = 100;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(TSCodeTableMetadata.ColumnNames.CodeSequence, 4, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = TSCodeTableMetadata.PropertyNames.CodeSequence;
			c.NumericPrecision = 10;
			m_columns.Add(c);
				
			c = new esColumnMetadata(TSCodeTableMetadata.ColumnNames.Value1, 5, typeof(System.String), esSystemType.String);
			c.PropertyName = TSCodeTableMetadata.PropertyNames.Value1;
			c.CharacterMaxLength = 50;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(TSCodeTableMetadata.ColumnNames.Value2, 6, typeof(System.String), esSystemType.String);
			c.PropertyName = TSCodeTableMetadata.PropertyNames.Value2;
			c.CharacterMaxLength = 200;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(TSCodeTableMetadata.ColumnNames.NumValue1, 7, typeof(System.Decimal), esSystemType.Decimal);
			c.PropertyName = TSCodeTableMetadata.PropertyNames.NumValue1;
			c.NumericPrecision = 18;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(TSCodeTableMetadata.ColumnNames.NumValue2, 8, typeof(System.Decimal), esSystemType.Decimal);
			c.PropertyName = TSCodeTableMetadata.PropertyNames.NumValue2;
			c.NumericPrecision = 18;
			c.NumericScale = 4;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(TSCodeTableMetadata.ColumnNames.EffectiveStartDate, 9, typeof(System.DateTime), esSystemType.DateTime);
			c.PropertyName = TSCodeTableMetadata.PropertyNames.EffectiveStartDate;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(TSCodeTableMetadata.ColumnNames.EffectiveEndDate, 10, typeof(System.DateTime), esSystemType.DateTime);
			c.PropertyName = TSCodeTableMetadata.PropertyNames.EffectiveEndDate;
			c.HasDefault = true;
			c.Default = @"('9998-12-31')";
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(TSCodeTableMetadata.ColumnNames.ParentID, 11, typeof(System.Decimal), esSystemType.Decimal);
			c.PropertyName = TSCodeTableMetadata.PropertyNames.ParentID;
			c.NumericPrecision = 18;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(TSCodeTableMetadata.ColumnNames.MapPath, 12, typeof(System.String), esSystemType.String);
			c.PropertyName = TSCodeTableMetadata.PropertyNames.MapPath;
			c.CharacterMaxLength = 50;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(TSCodeTableMetadata.ColumnNames.CreatedBy, 13, typeof(System.String), esSystemType.String);
			c.PropertyName = TSCodeTableMetadata.PropertyNames.CreatedBy;
			c.CharacterMaxLength = 50;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(TSCodeTableMetadata.ColumnNames.CreatedDate, 14, typeof(System.DateTime), esSystemType.DateTime);
			c.PropertyName = TSCodeTableMetadata.PropertyNames.CreatedDate;
			c.HasDefault = true;
			c.Default = @"(getdate())";
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(TSCodeTableMetadata.ColumnNames.LastedUpdatedBy, 15, typeof(System.String), esSystemType.String);
			c.PropertyName = TSCodeTableMetadata.PropertyNames.LastedUpdatedBy;
			c.CharacterMaxLength = 50;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(TSCodeTableMetadata.ColumnNames.LastedUpdatedDate, 16, typeof(System.DateTime), esSystemType.DateTime);
			c.PropertyName = TSCodeTableMetadata.PropertyNames.LastedUpdatedDate;
			c.HasDefault = true;
			c.Default = @"(getdate())";
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(TSCodeTableMetadata.ColumnNames.VersionNo, 17, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = TSCodeTableMetadata.PropertyNames.VersionNo;
			c.NumericPrecision = 10;
			c.IsNullable = true;
			m_columns.Add(c);
				
		}
		#endregion	
	
		static public TSCodeTableMetadata Meta()
		{
			return meta;
		}	
		
		public Guid DataID
		{
			get { return base.m_dataID; }
		}	
		
		public bool MultiProviderMode
		{
			get { return false; }
		}		

		public esColumnMetadataCollection Columns
		{
			get	{ return base.m_columns; }
		}
		
		#region ColumnNames
		public class ColumnNames
		{ 
			 public const string CodeID = "CodeID";
			 public const string CodeCategory = "CodeCategory";
			 public const string Code = "Code";
			 public const string CodeDesc = "CodeDesc";
			 public const string CodeSequence = "CodeSequence";
			 public const string Value1 = "Value1";
			 public const string Value2 = "Value2";
			 public const string NumValue1 = "NumValue1";
			 public const string NumValue2 = "NumValue2";
			 public const string EffectiveStartDate = "EffectiveStartDate";
			 public const string EffectiveEndDate = "EffectiveEndDate";
			 public const string ParentID = "ParentID";
			 public const string MapPath = "MapPath";
			 public const string CreatedBy = "CreatedBy";
			 public const string CreatedDate = "CreatedDate";
			 public const string LastedUpdatedBy = "LastedUpdatedBy";
			 public const string LastedUpdatedDate = "LastedUpdatedDate";
			 public const string VersionNo = "VersionNo";
		}
		#endregion	
		
		#region PropertyNames
		public class PropertyNames
		{ 
			 public const string CodeID = "CodeID";
			 public const string CodeCategory = "CodeCategory";
			 public const string Code = "Code";
			 public const string CodeDesc = "CodeDesc";
			 public const string CodeSequence = "CodeSequence";
			 public const string Value1 = "Value1";
			 public const string Value2 = "Value2";
			 public const string NumValue1 = "NumValue1";
			 public const string NumValue2 = "NumValue2";
			 public const string EffectiveStartDate = "EffectiveStartDate";
			 public const string EffectiveEndDate = "EffectiveEndDate";
			 public const string ParentID = "ParentID";
			 public const string MapPath = "MapPath";
			 public const string CreatedBy = "CreatedBy";
			 public const string CreatedDate = "CreatedDate";
			 public const string LastedUpdatedBy = "LastedUpdatedBy";
			 public const string LastedUpdatedDate = "LastedUpdatedDate";
			 public const string VersionNo = "VersionNo";
		}
		#endregion	

		public esProviderSpecificMetadata GetProviderMetadata(string mapName)
		{
			MapToMeta mapMethod = mapDelegates[mapName];

			if (mapMethod != null)
				return mapMethod(mapName);
			else
				return null;
		}
		
		#region MAP esDefault
		
		static private int RegisterDelegateesDefault()
		{
			// This is only executed once per the life of the application
			lock (typeof(TSCodeTableMetadata))
			{
				if(TSCodeTableMetadata.mapDelegates == null)
				{
					TSCodeTableMetadata.mapDelegates = new Dictionary<string,MapToMeta>();
				}
				
				if (TSCodeTableMetadata.meta == null)
				{
					TSCodeTableMetadata.meta = new TSCodeTableMetadata();
				}
				
				MapToMeta mapMethod = new MapToMeta(meta.esDefault);
				mapDelegates.Add("esDefault", mapMethod);
				mapMethod("esDefault");
			}
			return 0;
		}			

		private esProviderSpecificMetadata esDefault(string mapName)
		{
			if(!m_providerMetadataMaps.ContainsKey(mapName))
			{
				esProviderSpecificMetadata meta = new esProviderSpecificMetadata();			


				meta.AddTypeMap("CodeID", new esTypeMap("numeric", "System.Decimal"));
				meta.AddTypeMap("CodeCategory", new esTypeMap("varchar", "System.String"));
				meta.AddTypeMap("Code", new esTypeMap("varchar", "System.String"));
				meta.AddTypeMap("CodeDesc", new esTypeMap("varchar", "System.String"));
				meta.AddTypeMap("CodeSequence", new esTypeMap("int", "System.Int32"));
				meta.AddTypeMap("Value1", new esTypeMap("varchar", "System.String"));
				meta.AddTypeMap("Value2", new esTypeMap("varchar", "System.String"));
				meta.AddTypeMap("NumValue1", new esTypeMap("numeric", "System.Decimal"));
				meta.AddTypeMap("NumValue2", new esTypeMap("numeric", "System.Decimal"));
				meta.AddTypeMap("EffectiveStartDate", new esTypeMap("datetime", "System.DateTime"));
				meta.AddTypeMap("EffectiveEndDate", new esTypeMap("datetime", "System.DateTime"));
				meta.AddTypeMap("ParentID", new esTypeMap("numeric", "System.Decimal"));
				meta.AddTypeMap("MapPath", new esTypeMap("varchar", "System.String"));
				meta.AddTypeMap("CreatedBy", new esTypeMap("varchar", "System.String"));
				meta.AddTypeMap("CreatedDate", new esTypeMap("datetime", "System.DateTime"));
				meta.AddTypeMap("LastedUpdatedBy", new esTypeMap("varchar", "System.String"));
				meta.AddTypeMap("LastedUpdatedDate", new esTypeMap("datetime", "System.DateTime"));
				meta.AddTypeMap("VersionNo", new esTypeMap("int", "System.Int32"));			
				
				
				
				meta.Source = "T_S_CodeTable";
				meta.Destination = "T_S_CodeTable";
				
				meta.spInsert = "proc_T_S_CodeTableInsert";				
				meta.spUpdate = "proc_T_S_CodeTableUpdate";		
				meta.spDelete = "proc_T_S_CodeTableDelete";
				meta.spLoadAll = "proc_T_S_CodeTableLoadAll";
				meta.spLoadByPrimaryKey = "proc_T_S_CodeTableLoadByPrimaryKey";
				
				this.m_providerMetadataMaps["esDefault"] = meta;
			}
			
			return this.m_providerMetadataMaps["esDefault"];
		}

		#endregion

		static private TSCodeTableMetadata meta;
		static protected Dictionary<string, MapToMeta> mapDelegates;
		static private int _esDefault = RegisterDelegateesDefault();
	}
}
